from django.db import models
from utils.models import CoreModel, table_prefix
from system.menu.models import Menu


class Role(CoreModel):
    name = models.CharField(max_length=64, verbose_name="角色名称", help_text="角色名称")
    desc = models.CharField(max_length=255, null=True, blank=True, verbose_name='描述')
    sort = models.IntegerField(default=1, verbose_name="角色顺序", help_text="角色顺序")
    page_perms = models.ManyToManyField(to=Menu, verbose_name='关联菜单按钮权限', db_constraint=False, help_text="关联菜单",
                                        blank=True)

    class Meta:
        db_table = table_prefix + 'role'
        verbose_name = '角色表'
        verbose_name_plural = verbose_name
        ordering = ('sort',)
